#!/bin/bash
# chkconfig: 345 10 90 
# description: runsunloginclient

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

start() {
	/usr/local/sunlogin/bin/oray_rundaemon -e 'source /usr/local/sunlogin/etc/watch.sh' -d
}

stop() {
	psid=$(ps -ef | grep oray_rundaemon | grep -v grep | grep -v $0 | awk '{print $2}')
	if [ -n "$psid" ]; then
		kill -9 $psid
	fi 

	killall sunloginclient
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		stop
		sleep 3
		start
		;;
	status)
		status $0
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|condrestart|status}"
		exit 1
esac

